"use strict";

$(function()
{
	// Google references are not available until the page is loaded

	if (window.google !== undefined)
	{
		/**
		 * @type {String|Number}
		 * @const
		 */
		Enum.map.largeType = google.maps.MapTypeId.HYBRID;
		/**
		 * @type {String|Number}
		 * @const
		 */
		Enum.map.smallType = google.maps.MapTypeId.TERRAIN;
	}
});

/**
 * @type {Object}
 * @constructor
 */
function Enum() {}

/**
 * @type {String}
 * @const
 * @static
 */
Enum.title = 'Trail Image Photography';

/**
 * @enum {Number}
 * @const
 */
Enum.opacity =
{
	tocDisabled: 0.5,
	buttonDisabled: 0.3,
	buttonNormal: 0.6
};

/**
 * Default values for embedding
 * @enum {Number}
 * @const
 */
Enum.embed =
{
	height: 700,
	width: 1000
};

/**
 * Maximum number of photos to download in advance from Flickr
 * @type {Number}
 * @const
 * @static
 */
Enum.photoPreloadMax = 10;

/**
 * @type {Array.<String>}
 * @const
 * @static
 */
Enum.month = ['January','February','March','April','May','June','July','August','September','October','November','December'];

/**
 * @enum {String}
 * @const
 */
Enum.flickr =
{
	userID: '60950751@N04',
	api: 'http://api.flickr.com/services/rest/',
	key: 'afae0007b8557c339e5657d1ff8468de',
	favoriteSet: '72157631638576162',
	defaultCollection: '72157630885395608'
};

/**
 * @enum {String}
 * @const
 */
Enum.size =
{
	thumbnail:  'url_t',
	square75:	'url_sq',
	square150:  'url_q',
	small240:   'url_s',
	small320:   'url_n',
	medium500:  'url_m',
	medium640:  'url_z',
	medium800:  'url_c',
	large1024:  'url_l',
	large1600:  'url_h',
	large2048:  'url_k',
	original:   'url_o'
};

/**
 * @enum {String}
 * @const
 */
Enum.ExifSpace =
{
	IFD0: 'IFD0',
	IFD1: 'IFD1',
	ExifIFD: 'ExifIFD',
	GPS: 'GPS',
	Photoshop: 'Photoshop',
	IPTC: 'IPTC',
	IccView: 'ICC-view',
	IccMeasure: 'ICC-meas',
	XmpX: 'XMP-x',
	XmpXmp: 'XMP-xmp',
	XmpAux: 'XMP-aux',
	XmpPhotoshop: 'XMP-photoshop',
	XmpMM: 'XMP-xmpMM',
	XmpDC: 'XMP-dc',
	XmpRights: 'XMP-xmpRights',
	XmpIPTC: 'XMP-iptcCore',
	Adobe: 'Adobe'
};

/**
 * @enum {String|Number}
 * @const
 */
Enum.map =
{
	smallSize: 200,
	smallBorder: 4,
	/** Image size to display in map marker InfoWindow */
	thumbSize: Enum.size.small240,
	infoWindowSize: 250,
	largeBorder: 50
};

/**
 * @enum {Number|String}
 * @const
 */
Enum.filmstrip =
{
	small: 50,
	large: 150,
	border: 2,
	refreshRate: 60,
	thumbSize: Enum.size.square150
};

/**
 * @enum {Number}
 */
Enum.caption =
{
	maxHeight: 165
};

/**
 * @enum {String}
 * @const
 */
Enum.url =
{
	flickrPhoto: 'http://www.flickr.com/photos/trailimage/[photoID]/in/set-[setID]/',
	facebookAlbum: 'http://www.facebook.com/media/set/?set=a.[albumID].241863632579825&type=3',
	quotes: '/script/ti.quotes.js',
	wikipedia: 'http://en.wikipedia.org/wiki/'
};

/**
 * Maximum difference between photo and screen ratio before allowing overflow and panning
 * @const
 * @static
 */
Enum.maxRatioDiff = 0.4;

/**
 * @enum {RegExp}
 * @const
 */
Enum.pattern =
{
	haiku: /^([ \w]{5,100})\r*\n([ \w]{5,100})\r*\n([ \w]{5,100})[\t\r\n]*/gi,
	newLine: /(\r\n|\n|\r)/gm,
	superscript: /([¹²³])/g,
	url: /(http:\/\/[^\s\r\n]+)/g,
	link: /<a href=["']([^"']+)['"][^>]*>([^<])+<\/a>/g,
	footnotes: /<p><\/p>(<p>[¹²³].+)/gm,
	/**
	 * Facebook album ID to be inserted into Enum.url.facebookAlbum
	 * @example 296706240428897.53174
	 * @example 296706240428897.53174
	 */
	facebookID: /\d{15}\.\d{5}/g
};

/**
 * @enum {Number}
 * @const
 * @static
 */
Enum.duration =
{
	/** Time to move image on screen from one end to the other */
	pan: 4000,
	photoResize: 200,
	/** Time to show each image in slideshow */
	slide: 7000,
	/** Time to wait between setting image source of set photos */
	betweenDownloads: 500,
	/** Time to wait for window resize */
	windowResize: 800,
	captionResize: 500,
	crossfade: 1000
};
